using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Door : MonoBehaviour
{
    [Header("左侧开门")]public bool leftDoor;

    [Header("右侧开门")] public bool rightDoor;

    [Header("机关们")] public bool trapDoor;

    [SerializeField] private Trap[] traps;
    
    [Header("钥匙门")] public bool keyDoor;
    // [SerializeField]

    private void OnEnable()
    {
        EventHander.AllTrapDown += OnAllTrapDown;
    }

    private void OnDisable()
    {
        EventHander.AllTrapDown -= OnAllTrapDown;
    }

    private void OnAllTrapDown()
    {
        foreach (var obj in traps)
        {
            if(!obj.isTrapDown) return;
        }
        //TODO:打开门的状态 现在目前是失活
        gameObject.SetActive(false);
    }
}
